import Vue from 'vue';
import VueResource from 'vue-resource';
import store from './store';
import router from './router';
import { sync } from 'vuex-router-sync';
// import VueTouch from 'vue-touch';
import Comb from './vendor/index';
import * as filters from './filters';
import VueLazyload from 'vue-lazyload';
require('../static/js/vendor/fastclick'); // get fastclick
import app from './app.vue';

// sync the router with the vuex store.
// this registers `store.state.route`
sync(store, router);

// 注册 fastclick
document.addEventListener('DOMContentLoaded', function () {
    if (window.FastClick) window.FastClick.attach(document.body);
}, false);

// 注册vue-resource
Vue.use(VueResource);
// Vue.http.options.emulateJSON = true; // post 提交时，以表单形式提交

// 注册蜂巢（Comb）组件
Vue.use(Comb);

// // 注册vue-touch
// Vue.use(VueTouch, {name: 'v-touch'});

// // 注册转场动画
// import vTransition from './vendor/v-transition.js';
// Vue.use(vTransition, router, {
//     backAnim: 'fadeOutRight', // fadeOutRight, slideOutRight
//     forwardAnim: 'fadeInRight' // fadeInRight, slideInRight
// });

// 注册过滤器
Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key]);
});

// 延时加载
Vue.use(VueLazyload, {
    preLoad: 1.3,
    error: require('./assets/image-empty.png'),
    // error: '',
    // loading: '/static/images/loading.jpg',
    loading: require('../static/images/loading.jpg'),
    // loading: 'assets/loading.jpg',
    attempt: 1
});

new Vue({
    router,
    store,
    render: h => h(app)
    // ...app
}).$mount('#app');
